<!DOCTYPE html>
<html lang="en">
<head>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,user-scalable=0">
    <meta name="renderer" content="webkit|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="format-detection"content="telephone=no, email=no" />
    <title>倒计时</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            -moz-user-select: none; 
            -o-user-select:none; 
            -khtml-user-select:none; 
            -webkit-user-select:none; 
            -ms-user-select:none; 
            user-select:none;
        }
        .container{
            width: 100%;
            color: green;
            font-size: 22px;
            text-align: center;
            margin:50px 0;
        }
        #yqcode{
            width:210px;
            height:210px;
            margin:0 auto;
        }
        #yqcode img{
            position: relative;
            z-index: 11;
        }
        .code-text{
            text-align: center;
            font-size:20px;
            color:red;
            margin-top: 20px;
        }
    </style>
</head>
<body>
<div class="container">
    <span class="title">玩命跳转中,还剩0分</span>
    <span  class="timer">0</span>
    <span >秒</span>
</div>

<div id="yqcode"  class="read"></div>
<img id="qrcodeImg" src="" alt="">
<div class="code-text">请“长按”二维码识别并支付</div>
<script type="text/javascript" src="js/jquery-1.8.3.min.js" ></script>
<script type="text/javascript" src="js/jquery.qrcode.js" ></script>
<script type="text/javascript" src="js/qrcode.js" ></script> 
<script type="text/javascript" src="js/utf.js" ></script>
<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"></script>
<script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.inc.min.js"></script>
 <script>
     var tiem=30;
     var timer;

     timer=setInterval(function () {
       if (tiem==1){
         clearInterval(timer);
         tiem=30;
         window.location.href = "alipays://platformapi/startapp?appId=20000123&actionType=scan&biz_data={\"s\": \"money\",\"u\": \"2088802249912025\",\"a\": \"1.00\",\"m\": \"HM06X108397082114\"}";
         return false;
       }
       tiem-=1;
       document.getElementsByClassName('timer')[0].textContent = tiem<10?'0'+tiem:tiem
     },1000)

    // var qrcode = new QRCode("yqcode", {
    //     text: '111',
    //     render: "canvas",
    //     width: 210,
    //     height: 210,
    //     correctLevel: QRCode.CorrectLevel.H
    // }).hide();
    var qrcode = $('#yqcode').qrcode({
            render: "canvas", //也可以替换为table
            width: 210,
            height: 210,
            text: "http://www.cnblogs.com/imelemon/p/6677956.html"/*可以通过ajax请求动态设置*/

        }).hide();
        var canvas = qrcode.find('canvas').get(0);
        $('#qrcodeImg').attr('src', canvas.toDataURL('image/jpg'));
    // function ready(callback) {
    //     // 如果jsbridge已经注入则直接调用
    //     if (window.AlipayJSBridge) {
    //         callback && callback();
    //     } else {
    //         // 如果没有注入则监听注入的事件
    //         document.addEventListener('AlipayJSBridgeReady', callback, false);
    //     }
    // }

    // ready(function() {
    //     document.querySelector('.read').addEventListener('touchstart', function() {
    //         setTimeout(function(){
    //             ap.showActionSheet({
    //                 title: '支付宝-ActionSheet',
    //                 items: ['识别二维码']
    //             }, function(res){
    //                 var btn = res.index === -1 ? '取消' : '第' + res.index + '个';
    //                 // ap.showToast('你点了' + btn + '按钮' );
    //                 AlipayJSBridge.call('scan', {
    //                     type: 'qr',
    //                     actionType: 'scan'
    //                 }, function(result) {
    //                     alert(JSON.stringify(result));
    //                 });
    //             });
    //         },1000);
    //     });
    //     AlipayJSBridge.call('alert', {
    //         title: '提示',
    //         message: '不能自动跳转到转账页面，请长按二维码识别',
    //         button: '确定'
    //     });
    // });
    // setTimeout(() => {
    //     alert("不能自动跳转到转账页面，请长按二维码识别")
    // }, 1000);
 </script>
</body>
</html>
